<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width= , initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/react@17/umd/react.production.min.js" rel="external nofollow" rel="external nofollow"></script>

    <script src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js" rel="external nofollow" rel="external nofollow"></script>

    <script src="https://unpkg.com/babel-standalone@6/babel.min.js" rel="external nofollow" rel="external nofollow"></script>
</head>
<body>
    <div id="test"></div>
    <script type="text/babel">
        
        class Weather extends React.Component{
            
    constructor(props){
                super(props);
                // this.demo=this.demo.bind(this)
            }
            state={isHot:false}
     render(){
                const{isHot}=this.state;
                return <h1 onClick={this.demo}>今天天气很{isHot?'炎热':'凉爽'}</h1>
            }
      demo=()=>{
            const isHot=this.state.isHot
            this.setState({isHot:!isHot});
            }
        }
        ReactDOM.render(<Weather/>,document.getElementById('test'))
    </script>
</body>
</html>